#include "../httplib.h"
#include "as_model.hpp"

using namespace httplib;
using namespace emotion_as_model;

int main(int argc,char *argv[])
{
    if(argc!=2)
    {
        std::cerr<<"缺少命令行参数,启动执行有误!"<<std::endl;
        return 1;
    }

    Server svr;
    svr.Post("/emotion_analysis_model",[](const Request &req,Response &resp){
        std::string in_json=req.body;
        std::string out_json;
        if(!in_json.empty()){
            as_model::start(in_json,&out_json);
            resp.set_content(out_json,"application/json;charset=utf-8");
        }
    });

    /*0.0.0.0 8081*/
    svr.listen("0.0.0.0",atoi(argv[1]));

    return 0;
}
